﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VitCode.Castle.DataAccess;

namespace VitCode.Web.BackStageManagement
{
    public partial class MainLeft : VcPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
                if(String.IsNullOrEmpty(GenericContext.CurrUserCode) || !GenericContext.CheckCurrUserIsAdmin())
                {
                    Response.Redirect("../Default.aspx");
                }
                AdminMenuTreeShow();
            }
        }

        public void AdminMenuTreeShow()
        {

            TreeNode nodeRoot = new TreeNode();
            nodeRoot.ImageUrl = "Images/outbox.gif";
            nodeRoot.Text = "NSCS系統環境設置";
            nodeRoot.SelectAction = TreeNodeSelectAction.Expand;
            TreeView_Menu.Nodes.Add(nodeRoot);
            TreeView_Menu.Target = "MainFrame";
            nodeRoot.Expanded = true;

             

                TreeNode nodeMenu = new TreeNode();
                nodeMenu.ImageUrl = "Images/phiz.gif";
                nodeMenu.Text = "功能表管理";
                nodeMenu.SelectAction = TreeNodeSelectAction.Expand;
                nodeMenu.NavigateUrl = "MenuList.aspx";
                nodeRoot.ChildNodes.Add(nodeMenu);

                TreeNode nodeAdmin = new TreeNode();
                nodeAdmin.ImageUrl = "Images/phiz.gif";
                nodeAdmin.Text = "部門管理";
                nodeAdmin.SelectAction = TreeNodeSelectAction.Expand;
                nodeAdmin.NavigateUrl = "UserGroupList.aspx";
                nodeRoot.ChildNodes.Add(nodeAdmin);

                TreeNode nodeUser = new TreeNode();
                nodeUser.ImageUrl = "Images/phiz.gif";
                nodeUser.Text = "用戶管理";
                nodeUser.SelectAction = TreeNodeSelectAction.Expand;
                nodeUser.NavigateUrl = "UserList.aspx";
                nodeRoot.ChildNodes.Add(nodeUser);

                TreeNode nodeGroup = new TreeNode();
                nodeGroup.ImageUrl = "Images/phiz.gif";
                nodeGroup.Text = "角色管理";
                nodeGroup.SelectAction = TreeNodeSelectAction.Expand;
                nodeGroup.NavigateUrl = "RoleList.aspx";
                nodeRoot.ChildNodes.Add(nodeGroup);

               

                TreeNode nodeData = new TreeNode();
                nodeData.ImageUrl = "Images/phiz.gif";
                nodeData.Text = "許可權管理";
                nodeData.SelectAction = TreeNodeSelectAction.Expand;
                nodeData.NavigateUrl = "PermissionSet.aspx";
                nodeRoot.ChildNodes.Add(nodeData);

          
        }
    }
}
